package com.xjnt.mnui.controller;

import com.xjnt.frameworks.annotation.AutoInject;
import com.xjnt.frameworks.annotation.Router;
import com.xjnt.frameworks.core.CRUDController;
import com.xjnt.frameworks.exception.BusinessException;
import com.xjnt.frameworks.web.message.RetMsg;
import com.xjnt.mnui.entity.Portal;
import com.xjnt.mnui.service.PortalService;

@Router(name="/mnui/ai/portal", view="/mnui/portal")
public class PortalController extends CRUDController<Portal, PortalService> {
	
	@AutoInject
	private PortalService portalService;
	
	@Override
	protected String getBizName() {
		return "门户";
	}
	
	@Override
	protected Class<Portal> getClazz() {
		return Portal.class;
	}

	@Override
	protected PortalService getService() {
		return portalService;
	}
	
	public void setDefault(){
		RetMsg retMsg = new RetMsg();
		try{
			String uuid = getPara("uuid");
			boolean flag = getService().updateDefalut(uuid);
			if(flag){
				retMsg.pushOk("设置默认门户成功");
			} else {
				retMsg.pushError("设置默认门户失败");
			}
			renderJson(retMsg);
		} catch (Exception ex){
			throw new BusinessException("设置默认" + getBizName(), "发生异常：", ex);
		}
	}
}
